<?php
class C_PrescriptionNote extends Controller{
	function C_PrescriptionNote($template_mod = "general") {
		parent::Controller();
		if (Celini::getCurrentController() == 'PrescriptionNote') {
			$menu =& Menu::getInstance();
			$menu->currentSection = 'admin';
		}
		$this->template_mod = $template_mod;				
		$this->view->path = 'prescription_note';
		$this->setLayout('admin');
	}
	
	public function actionManagement(){
		return $this->view->render('prescription_note_management.html');
	}
	
	public function actionListPrescriptionNotes(){
		$noteList = Celini::newORDO('PrescriptionNote')->listAllNotes();
		$this->assign('notes', $noteList);
		return $this->view->render('note_list.html');
	}
	
	public function actionEditPrescriptionNotes(){
		$id		=	$_GET['note_id'];
		$pnote	=	Celini::newORDO('PrescriptionNote');
		
		if (isset($id) && $id != "") {
			$pnote->setup($id);
		}
		
		$this->assign('note', $pnote);
		return $this->view->render('edit_pnote.html');
	}
	
	public function actionSavePrescriptionNoteAjax(){
		$pnoteId=	$_POST['pnote_id'];
		$note	=	$_POST['note'];
		$res	=	Celini::newORDO('PrescriptionNote')->addEditPrescriptionNote($pnoteId, $note);
		return $res;
	}
	
	public function actionChangePNoteStatusAjax(){
		$pnoteId	=	$_GET['id'];
		$status		=	$_GET['status'];
		$pnote = Celini::newORDO('PrescriptionNote', $id);
		if($status == 'lock'){
			$pnote->disableNote($pnoteId);
		}
		else if($status == 'unlock'){
			$pnote->enableNote($pnoteId);
		}
	}
}
?>